<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}
</script>
<body>
This tests that calling document.open on a document that has a pending load correctly cancels the load and does not crash even if the frame is removed.
<script>
const div = document.body.appendChild(document.createElement("div"));
div.innerHTML = "<iframe src='data:text/html,'></iframe>";
const frame = div.childNodes[0];
const client = new frame.contentWindow.XMLHttpRequest();
client.open("GET", "data:text/html,");
client.onabort = e => {
  div.remove();
  testRunner.notifyDone();
};
client.send();
frame.contentWindow.document.open();
</script>
</body>
